<?
    class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
    {   
        protected function _initView ()
        {
            $view = new Zend_View();
            $view->doctype("HTML5");
            $view->headTitle("Principio");
            $view->env = APPLICATION_ENV;
            $view->setHelperPath(APPLICATION_PATH."/views/helpers", "Principio_View_Helper");
            $view->headLink()->prependStylesheet("/css/style.css", "all");
            $view->headLink(['rel' => "favicon", 'href' => "/img/favicon.ico"], "PREPEND");
            $view->headScript()
                ->appendFile("/js/jquery-1.7.1.js")
                ->appendFile("/js/ajax.js")
                ->appendFile("/js/script.js");
            $view->headMeta()->appendHttpEquiv("Content-Type", "text/html;  charset = UTF-8");

            // Add it to the ViewRenderer
            $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper("ViewRenderer");
            $viewRenderer->setView($view);
 
            // Return it, so that it can be stored by the bootstrap
            return $view;
        }


        protected function _initAutoload()
        {
            Zend_Loader_Autoloader::getInstance()
                ->registerNamespace("Principio_")
                ->registerNamespace("PrincipioLab_")
                ->registerNamespace("CM_");
        }


        protected function _initPlugin()
        {
            Zend_Controller_Front::getInstance()
                ->registerPlugin(new Principio_Controller_Plugin());
        }


        protected function _initLog()
        {
            $configuration = $this->getOption("principio");

            $logger = new CM_Log($configuration['log']['path']);
            Zend_Registry::set("Logger", $logger);
        }


        /*
        public function run()
        {
            $auth = Zend_Auth::getInstance();
            $request_http = new Zend_Controller_Request_Http();

            if (($request_http->isPost()) || (($request_http->isGet()) && (substr($request_http->getRequestUri(), 0, 5) != "/prv?")))
            {
                if ($auth->hasIdentity())
                {
                    // Authenticated
                    if (($request_http->getRequestUri() == "/") || ($request_http->getRequestUri() == "/admin"))
                    {
                        // Non-Ajax request
                        Zend_Layout::startMvc();
                        $layout = Zend_Layout::getMvcInstance();
                        $layout->setLayout("layout");
                    }
                    else
                        Zend_Layout::getMvcInstance()->disableLayout();
                }
                else
                {
                    // Require authentication
                    if ($request_http->getRequestUri() != "/auth")
                    {
                        $front = Zend_Controller_Front::getInstance();
                        $response_http = new Zend_Controller_Response_Http();
                        $response_http->setRedirect("/auth");
                        $front->setResponse($response_http);
                    };
                };
            }
            else
            {
                Zend_Layout::getMvcInstance()->disableLayout();
            };
            
            return parent::run();
        }
        */
}